using System;
using System.ComponentModel;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using PickGold.Charting.Utilities;

namespace PickGold.Charting
{
	[AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
	[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
	public abstract class ChartElement : IChartElement, IDisposable
	{
		private CommonElements _common;
		private IChartElement _parent;
		private object _tag;

		protected ChartElement()
		{
		}

		internal ChartElement(IChartElement parent)
		{
			this._parent = parent;
		}

		public void Dispose()
		{
			this.Dispose(true);
			GC.SuppressFinalize(this);
		}

		protected virtual void Dispose(bool disposing)
		{
		}

		public override bool Equals(object obj)
		{
			return this.EqualsInternal(obj);
		}

		internal virtual bool EqualsInternal(object obj)
		{
			return base.Equals(obj);
		}

		public override int GetHashCode()
		{
			return base.GetHashCode();
		}

		internal virtual void Invalidate()
		{
			if (this._parent != null)
			{
				this._parent.Invalidate();
			}
		}

		void IChartElement.Invalidate()
		{
			this.Invalidate();
		}

		public override string ToString()
		{
			return this.ToStringInternal();
		}

		internal virtual string ToStringInternal()
		{
			return base.GetType().Name;
		}

		internal Chart Chart
		{
			get
			{
				if (this.Common != null)
				{
					return this.Common.Chart;
				}
				return null;
			}
		}

		internal CommonElements Common
		{
			get
			{
				if ((this._common == null) && (this._parent != null))
				{
					this._common = this._parent.Common;
				}
				return this._common;
			}
			set
			{
				this._common = value;
			}
		}

		internal virtual IChartElement Parent
		{
			get
			{
				return this._parent;
			}
			set
			{
				this._parent = value;
			}
		}

		CommonElements IChartElement.Common
		{
			get
			{
				return this.Common;
			}
		}

		IChartElement IChartElement.Parent
		{
			get
			{
				return this._parent;
			}
			set
			{
				this.Parent = value;
			}
		}

		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false), SerializationVisibility(SerializationVisibility.Hidden), DefaultValue((string)null)]
		public object Tag
		{
			get
			{
				return this._tag;
			}
			set
			{
				this._tag = value;
			}
		}
	}
}

